package ${package.Controller};

import org.springframework.web.bind.annotation.RequestMapping;
import com.tanjie.blackbean.web.annotation.BlackBeanController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tanjie.blackbean.mybatis.query.PageParam;
import ${package.Service}.${table.serviceName};
import ${package.Entity}.${entity};
import ${package.Entity}.${entity}DTO;
import ${package.Entity}.${entity}VO;
import ${package.Entity}.${entity}Query;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>
/**
 * ${table.comment!}
 *
 * @author ${author}
 * @since ${date}
 */
@Tag(name = "${table.comment!}")
@BlackBeanController
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    @Resource
    I${entity}Service ${entity?uncap_first}Service;

    @Operation(summary = "新增")
    @PostMapping("create")
    public void create${entity}Handler(@RequestBody @Validated ${entity}DTO dto) {
        ${entity?uncap_first}Service.create(dto);
    }

    @Operation(summary = "更新")
    @PostMapping("update")
    public void update${entity}Handler(@RequestBody @Validated ${entity}DTO dto) {
        ${entity?uncap_first}Service.update(dto);
    }

    @Operation(summary = "删除")
    @GetMapping("delete")
    public void delete${entity}Handler(String id) {
        ${entity?uncap_first}Service.delete(id);
    }

    @Operation(summary = "获取详情")
    @GetMapping("detail")
    public ${entity}VO get${entity}DetailHandler(String id) {
        return ${entity?uncap_first}Service.detail(id);
    }

    @Operation(summary = "列表查询")
    @PostMapping("list")
    public List<${entity}VO> query${entity}ListHandler(@RequestBody(required = false) ${entity}Query dto) {
        return ${entity?uncap_first}Service.queryList(dto);
    }

    @Operation(summary = "分页查询")
    @PostMapping("page")
    public IPage<${entity}VO> queryPageListHandler(@RequestBody(required = false) ${entity}Query dto, PageParam pageParam) {
        return ${entity?uncap_first}Service.queryPage(dto, pageParam);
    }

}
</#if>
